'use strict';

angular.module('app')
    .config(['$stateProvider', '$urlRouterProvider',
        function ($stateProvider, $urlRouterProvider) {
            $stateProvider.state('app.bpm', {
                url: '/bpm',
                template: '<div ui-view class="fade-in-right-big smooth"></div>',
                data: {
                    authorities: ['IS_AUTHENTICATED_FULLY']
                },
                resolve: {
                    deps: ['$ocLazyLoad',
                        function ($ocLazyLoad) {
                            return $ocLazyLoad.load(['tpl/bpm/state.js']);
                        }]
                }
            })
                .state('app.bpm.manager', {
                    url: '/manager',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.manager.definition', {
                    url: '/definition',
                    templateUrl: 'tpl/bpm/manager/processDefinition/definition.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['dialogs.main', 'dDatepicker']).then(function () {
                                    return $ocLazyLoad.load(['tpl/bpm/manager/processDefinition/definition.js']);
                                });
                            }]
                    }
                })
                .state('app.bpm.manager.deploy', {
                    url: '/deploy',
                    templateUrl: 'tpl/bpm/manager/processDefinition/deploy.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['angularFileUpload']).then(
                                    function () {
                                        return $ocLazyLoad.load(['tpl/bpm/manager/processDefinition/deploy.js']);
                                    }
                                );
                            }]
                    }
                })
                .state('app.bpm.manager.processinstance', {
                    url: '/processinstance',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.manager.processinstance.list', {
                    url: '/list',
                    templateUrl: 'tpl/bpm/manager/processinstance/list.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            //function( $ocLazyLoad ){
                            //    return $ocLazyLoad.load(['dialogs.main','dDatepicker']).then(function(){
                            //        return $ocLazyLoad.load(['tpl/bpm/manager/processDefinition/definition.js']);
                            //    });
                            //}]
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load([
                                    'tpl/bpm/manager/processinstance/list.js', 'tpl-common/inputDialog.js'
                                ]);
                            }]
                    }
                })
                .state('app.bpm.manager.process', {
                    url: '/process',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.manager.process.trace', {
                    url: '/trace',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.manager.process.trace.view', {
                    url: '/view/:executionId',
                    templateUrl: 'tpl/bpm/manager/trace/view.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['dialogs.main']).then(function () {
                                    return $ocLazyLoad.load(['tpl/bpm/manager/trace/view.js']);
                                });
                            }]
                    }
                })
                .state('app.bpm.manager.processlist', {
                    url: '/processlist',
                    templateUrl: 'tpl/bpm/manager/process/list.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['tpl/bpm/manager/process/list.js']);
                            }]
                    }
                })
                .state('app.bpm.manager.processStart', {
                    url: '/processStart/:processDefinitionId',
                    templateUrl: 'tpl/bpm/manager/process/start.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['dDatepicker']).then(function () {
                                    return $ocLazyLoad.load(['tpl/bpm/manager/process/start.js']);
                                });
                            }]
                    }
                })
                .state('app.bpm.manager.execution', {
                    url: '/execution',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.manager.execution.list', {
                    url: '/list',
                    templateUrl: 'tpl/bpm/manager/execution/list.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['tpl/bpm/manager/execution/list.js']);
                            }]
                    }
                })
                .state('app.bpm.manager.task', {
                    url: '/task',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.manager.task.list', {
                    url: '/list',
                    templateUrl: 'tpl/bpm/manager/task/list.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['tpl/bpm/manager/task/list.js']);
                            }]
                    }
                })
                .state('app.bpm.manager.task.form', {
                    url: '/taskForm/:taskId',
                    templateUrl: 'tpl/bpm/manager/task/taskForm.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load(['angularFileUpload', 'dDatepicker']).then(function () {
                                    return $ocLazyLoad.load(['tpl/bpm/manager/task/taskForm.js']);
                                });
                            }]
                    }
                })
                .state('app.bpm.history', {
                    url: '/history',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.history.finsh', {
                    url: '/finsh',
                    template: '<div ui-view class="fade-in-right-big smooth"></div>',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    }
                })
                .state('app.bpm.history.finsh.list', {
                    url: '/list',
                    templateUrl: 'tpl/bpm/history/list.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load([]).then(function () {
                                    return $ocLazyLoad.load(['tpl/bpm/history/list.js']);
                                });
                            }]
                    }
                })
                .state('app.bpm.history.finsh.view', {
                    url: '/view/:processInstanceId',
                    templateUrl: 'tpl/bpm/history/view.html',
                    data: {
                        authorities: ['IS_AUTHENTICATED_FULLY']
                    },
                    resolve: {
                        deps: ['$ocLazyLoad',
                            function ($ocLazyLoad) {
                                return $ocLazyLoad.load([]).then(
                                    function () {
                                        return $ocLazyLoad.load(['tpl/bpm/history/view.js']);
                                    }
                                );
                            }]
                    }
                })
        }])